package com.example.springtransaction.service;

import com.example.springtransaction.mapper.LogInfoMapper;
import com.example.springtransaction.model.LogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

@Service
public class LogInfoService {
    @Autowired
    LogInfoMapper logInfoMapper;

    @Transactional
    public int addLog(LogInfo logInfo){
        int ret = logInfoMapper.addLog(logInfo);
        try {
            int num = 10/ 0;
        }catch (Exception e){
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return ret;
    }
}

